home *** CD-ROM | disk | FTP | other *** search
/ Ray Dream Studio / Ray Dream Studio (CDRAYD1) (Ray Dream) (1995).iso / DREAMSDK.WIN / INCLUDE / 3DCOFAIL.CPP < prev    next >
C/C++ Source or Header  |  1995-11-04  |  2KB  |  106 lines

  1. /* $Id: 3DCOFAIL.CPP 1.2 1995/11/04 14:51:27 YannPC Exp $ */
  2. /*****************************************************************************\
  3. *                                                                             *
  4. * 3DCoFail.cpp                                                                              *
  5. *           Failure handling for COM extensions                               *
  6. *                                                                             *
  7. *           Copyright (c) 1995, Ray Dream, Inc. All rights reserved.          *
  8. *                                                                             *
  9. \*****************************************************************************/
  10.  
  11. #ifndef __3DCOFAIL__
  12. #include "3DCoFail.h"
  13. #endif
  14.  
  15. #ifndef __I3DSHUTI__
  16. #include "I3DShUti.h"
  17. #endif
  18.  
  19. #include "String.h"
  20.  
  21. IShUtilities* gShellUtilities = NULL;
  22.  
  23. extern "C" {
  24. RDsetjmpProc    RDsetjmp;
  25. }
  26.  
  27. // Initialize gShellUtilities. Must be called to have working failure handling
  28. void InitCoFailure(IShUtilities* shellUtilities)    {
  29.     gShellUtilities = shellUtilities;
  30.     RDsetjmp = (RDsetjmpProc) shellUtilities->GetSetJmpAddress();
  31.     }
  32.  
  33. void FailNIL(void* apointer)    {
  34.     if (!apointer)    {
  35.         Failure(-1, 0);
  36.         }
  37.     }
  38.  
  39. void FailOSErr(short err)    {
  40.     if (err)    {
  41.         Failure(err, 0);
  42.         }
  43.     }
  44.  
  45. void __cdecl Failure(short error, long message)    {
  46.     if (gShellUtilities)    {
  47.         gShellUtilities->Failure(error, message);
  48.         }
  49.     }
  50.  
  51. FailInfoPtr* __cdecl GetGTopHandler()    {
  52.     if (gShellUtilities)    {
  53.         return (FailInfoPtr*) gShellUtilities->GetGTopHandler();
  54.         }
  55.     else    {
  56.         return NULL;
  57.         }
  58.     }
  59.  
  60. void* RDmalloc(unsigned long  size)    {
  61.     if (gShellUtilities)    {
  62.         return gShellUtilities->Malloc(size);
  63.         }
  64.     else    {
  65.         return NULL;
  66.         }
  67.     }
  68.  
  69. void* RDcalloc(unsigned long nmemb, unsigned long size)    {
  70.     if (gShellUtilities)    {
  71.         return gShellUtilities->Calloc(nmemb, size);
  72.         }
  73.     else    {
  74.         return NULL;
  75.         }
  76.     }
  77.  
  78. void* RDrealloc(void* ptr, unsigned long  size)    {
  79.     if (gShellUtilities)    {
  80.         return gShellUtilities->Realloc(ptr, size);
  81.         }
  82.     else    {
  83.         return NULL;
  84.         }
  85.     }
  86.  
  87. void* RDcrealloc(void* ptr, unsigned long  size)    {
  88.     if (gShellUtilities)    {
  89.         return gShellUtilities->Crealloc(ptr, size);
  90.         }
  91.     else    {
  92.         return NULL;
  93.         }
  94.     }
  95.  
  96. void RDfree(void* ptr)    {
  97.     if (gShellUtilities)    {
  98.         gShellUtilities->Free(ptr);
  99.         }
  100.     }
  101.  
  102.  
  103. void RDmemmove(void * dstPtr, void const * srcPtr, long size)    {
  104.     memmove(dstPtr, srcPtr, size);
  105.     }
  106.